{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">导入客户</label>
                <div class="layui-inline">
                    <button type="button" class="layui-btn import_excel"><i class="layui-icon">&#xe61f;</i> 选择文件</button>
                </div>
                <div class="layui-inline">
                    <a href="/static/excel/customer.xls" class="layui-btn layui-btn-danger"><i class="layui-icon">&#xe601;</i> 下载模板</a>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="js"}
<script>
    upload.render({
        elem: '.import_excel',
        url: '/crm/customer/import',
        accept: 'file', // 普通文件
        exts:'xls|xlsx',
        done: function (result) {
            if (result.code === 1) {
                layer.msg(result.msg, {icon: 1});
                setTimeout(function () {
                    parent.location.reload();
                }, 1000);
            }
            layer.close(index);
            layer.msg(result.msg, {icon: 1});
        }
    });
</script>
{/block}